{include file="public/header" $title="登陆" /}
</header>
<body>
<div style="padding: 20px; background-color: #F2F2F2;width: 400px;margin: 200px auto">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header" style="text-align: center">
                    <h2>Ecms通用管理后台</h2>
                </div>
                <div class="layui-card-body">
                    <form class="layui-form layui-form-pane" action="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">账号</label>
                            <div class="layui-input-block">
                                <input type="text" name="username" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
                            </div>
                        </div>
                        <!--<div class="layui-form-item">
                            <label class="layui-form-label">短输入框</label>
                            <div class="layui-input-inline">
                                <input type="text" name="username" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>-->


                        <div class="layui-form-item">
                            <label class="layui-form-label">密码</label>
                            <div class="layui-input-block">
                                <input type="password" lay-verify="pass" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input" maxlength="12" >
                            </div>
                        </div>

                        <div class="layui-form-item" style="margin-top: 30px">
                            <button class="layui-btn" type="button" lay-submit="" lay-filter="subbtn" style="width: 100%">登陆</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['form', 'layedit'], function(){
        var form = layui.form
                ,layer = layui.layer

        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 6){
                    return '账号在6到12位以上非特殊字符';
                }
            }
            ,pass: [/(.+){6,12}$/, '密码格式错误']
        });

        //监听提交
        form.on('submit(subbtn)', function(data){
            //console.log(data.field)
            $.post("{:url('nadmin/login/login')}",data.field,function(obj){
                if(obj.status==1){
                    layer.msg('登陆中...', {
                        icon: 16
                        ,shade: 0.01
                        ,time:1000
                    },function(index){
                        //跳转到首页
                       // console.log("{:url('index/index/index')}");
                        window.location.href="{:url('nadmin/index/index')}";
                    });
                }else{
                    //登陆失败
                    layer.msg(obj.msg,{icon:2});
                }
            },'json')
            return false;
        });

    });
</script>
</html>